<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <body class="tundra">
    <div id="systemMessage"></div>
    <div dojoType="dijit.Dialog" jsId="editsearchcpyfDialog" title="分公司信息修改">
    <form method="post" id="sendsavesubcompanyform">
            <table>
             <tr><td></td>
                 <td>
                 <input dojoType="dijit.form.TextBox" jsId="editsearchcpyid" type="text" name="id"></td></tr>
             <tr><td><label for="editsearchcpyname">分公司名:</label></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="editsearchcpyname" type="text" name="name"></td></tr>
             <tr><td><label for="editsearchcpyadd">地址:</label></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="editsearchcpyadd" type="text" name="address"></td></tr>
             <tr><td><label for="editsearchcpymemo">备注:</label></td>
                 <td><input type="text" dojoType="dijit.form.TextBox" jsId="editsearchcpymemo" name="memo">
                 </td></tr>
             <tr><td align="center" colspan="2">
                 <button dojoType="dijit.form.Button">保存
                   <script type="dojo/method" event="onClick">
                    var items = searchsucompanygrid.selection.getSelected();
                    saveSubcompanyForTable();
                    searchsucompanystore.setValue(items[0], "name",editsearchcpyname.getValue());
                    searchsucompanystore.setValue(items[0], "address",editsearchcpyadd.getValue());
                    searchsucompanystore.setValue(items[0], "memo",editsearchcpymemo.getValue());
                    editsearchcpyfDialog.hide();
                   </script>
                 </button>
                 <button dojoType="dijit.form.Button" type="button" onClick="editsearchcpyfDialog.hide();">取消</button></td></tr>
            </table>
    </form>
    </div>
    
    <div jsId="editschsubcpyfSyinfoialog" title="系统消息" dojoType="dijit.Dialog">
        <table>
        <tr><td>请您先选中用户</td></tr>
        <tr><td align="center">
             <button dojoType="dijit.form.Button" type="button" onClick="editschuserfCmDialog.hide();">确定
               <script type="dojo/method" event="onClick">
                    editschsubcpyfSyinfoialog.hide();
               </script>
             </button> 
        </td></tr>
        </table>            
    </div>
    <div dojoType="dijit.Dialog" jsId="delschcpyCmDialog" title="系统消息">
            <table>
              <tr><td><label id="delusermessage" for="editschusername">确定删除？</label></td>
                 <td></td></tr>
              <tr><td></td></tr>
              <tr><td align="center" colspan="2">
                 <button dojoType="dijit.form.Button" type="submit">确认
                   <script type="dojo/method" event="onClick">
                    var items = searchsucompanygrid.selection.getSelected();
                    if (items.length) {
                        dojo.forEach(items, function(selectedItem) {
                            if (selectedItem !== null) {
                                searchsucompanystore.deleteItem(selectedItem);
                                deleteSubcompanyForTable(selectedItem);
                            }
                        });
                    }
                   </script>
                 </button>
                 <button dojoType="dijit.form.Button" type="button" onClick="delschcpyCmDialog.hide();">取消</button></td></tr>
            </table>
    </div>
    <br>
    <div id="searchuser">
        <label for="username">按公司名检索:</label>
        <input name="username" dojoType="dijit.form.TextBox" jsId="searchcpy_cpyname" value="" intermediateChanges="true" trim="true" required="true">
        <button dojoType="dijit.form.Button" name="submitButton">开始搜索
           <script type="dojo/method" event="onClick">
               searchCompanyForTable();
           </script>
        </button>
    </div>
    <br><br>
    <button dojoType="dijit.form.Button" jsId="nextUserButton">删除
      <script type="dojo/method" event="onClick" args="evt">
              var items = searchsucompanygrid.selection.getSelected();
               if (items.length) {
                  delschcpyCmDialog.show();
                  delschcpyCmDialog.setAttribute("title", "删除用户"+items[0].name);
               } else {
                  editschuserfSyinfoialog.show();
               }
      </script>
    </button>

    <button dojoType="dijit.form.Button" jsId="nextUserButton">编辑
      <script type="dojo/method" event="onClick" args="evt">
              var items = searchsucompanygrid.selection.getSelected();
               if (items.length) {
                   dojo.forEach(items, function(item) {
                   if (item !== null) {
                       editsearchcpyfDialog.show();
                       editsearchcpyid.setValue(item.id);
                       editsearchcpyname.setValue(item.name);
                       editsearchcpyadd.setValue(item.address);
                       editsearchcpyid.setAttribute("style","visibility:hidden");
                       //editsearchcpyid.setAttribute("disabled",true);
                       editsearchcpymemo.attr("value",item.memo);
                   }});
               } else {
                   editschsubcpyfSyinfoialog.show();
               }
       </script>
    </button>

    <br>
        <span dojoType="dojo.data.ItemFileWriteStore" rowSelector="20px" jsId="searchsucompanystore" url="searchsubcpy.action?currentPage=0"> </span>
        <div jsId="searchsucompanygrid" dojoType="dojox.grid.EnhancedGrid" style="width: 98%; height: 70%;" structure="searchsubcompanylayout" selectionMode="single" store="searchsucompanystore" plugins="{nestedSorting: true, dnd: true, indirectSelection:true}">
        </div>
    </body>
</html>

